package com.run2code.design.structural.facade;

/**
 * 支付网关的外观类
 * 关注公众号【奔跑的码畜】，一起进步不迷路
 *
 * @author 第七人格
 * @date 2023/12/07
 */
public class PaymentFacade implements PaymentGateway {
    private static volatile PaymentFacade INSTANCE;

    private PaymentFacade() {
    }

    public static PaymentFacade getInstance() {
        if (null == INSTANCE) {
            synchronized (PaymentFacade.class) {
                if (null == INSTANCE) {
                    INSTANCE = new PaymentFacade();
                }
            }
        }
        return INSTANCE;
    }


    @Override
    public void pay(String amount) {
        // 使用工厂获取对象
        PaymentFactory.getGatewayService(amount).pay(amount);
    }
}
